{include file="public/_header" /}
<style>
    #mainForm {
        max-width: 700px;
        margin: 30px auto;
    }

    #mainForm .layui-form-item {
        margin-bottom: 25px;
    }
</style>
<body>
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-card-body">
                <span class="layui-breadcrumb" lay-separator="->" style="visibility: visible;">
                    <a href="{:url('auth/index/welcome')}">首页</a>
                    <a href="{:url('admin/config/index')}">系统配置</a>
                    <a><cite>添加系统配置</cite></a>
                </span>
        </div>
<!--        <div class="layui-card-header">{$title}</div>-->
        <div class="layui-card-body">
            <form class="layui-form" id="mainForm">
                <div class="layui-form-item">
                    <label class="layui-form-label layui-form-required">标题:</label>
                    <div class="layui-input-block">
                        <input name="title" id="title" placeholder="请输入" class="layui-input"
                               lay-verType="tips" required >
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label layui-form-required">类型:</label>
                    <div class="layui-input-block">
                        <input name="type" id="type" placeholder="请输入" class="layui-input"
                               lay-verType="tips" required >
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label layui-form-required">类型值:</label>
                    <div class="layui-input-block">
                        <input name="value" id="value" placeholder="请输入" class="layui-input"
                               lay-verType="tips" required >
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label layui-form-required">备注:</label>
                    <div class="layui-input-block">
                        <textarea name="remark" id="remark" placeholder="请输入备注" class="layui-textarea" lay-vertype="tips"></textarea>
                    </div>
                </div>

                <div class="form-group-bottom center-block">
                    <button type="reset" class="layui-btn layui-btn-primary">&emsp;重置&emsp;</button>
                    <button class="layui-btn" lay-filter="add" lay-submit>&emsp;提交&emsp;</button>
                </div>
            </form>
        </div>
    </div>
</div>
{include file="public/_footer"}
<script>
    layui.use(['form', 'element'], function () {
        var form = layui.form;
        var $ = layui.jquery;
        form.on('submit(add)', function (data) {
            var arr = data.field;
            // 提交数据
            $.post('{:url("add")}', arr, function (res) {
                if(res.code === 0) {
                    layer.msg(res.msg);
                    setTimeout(function () {
                        window.location.href = "{:url('index')}";//'index.html';
                    },500);
                    // layer.open({
                    //     type: 1
                    //     ,offset: 'auto'
                    //     ,id: 'layerDemo' //防止重复弹出
                    //     ,content: '<div style="padding: 20px 100px;">'+ res.msg +'</div>'
                    //     ,btn: '关闭'
                    //     ,btnAlign: 'c' //按钮居中
                    //     ,shade: 0 //不显示遮罩
                    //     ,yes: function(){
                    //         window.location.href = "{:url('index')}";//'index.html';
                    //         layer.closeAll();
                    //     }
                    // });
                    // layer.msg(res.msg);
                    // window.location.href = "{:url('index')}";//'index.html';
                }else {
                    layer.msg(res.msg);
                }
            },'JSON');
            return false;
        });
    });

</script>
</body>
</html>